package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.DisplayExample;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DisplayExampleDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "案例名称")
    private String name;

    @ApiModelProperty(value = "案例图片")
    private String url;

    @ApiModelProperty(value = "案例内容")
    private String details;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;


    public DisplayExampleDTO() {}

    public DisplayExampleDTO(DisplayExample entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static DisplayExampleDTO convert(DisplayExample entity) {
        return new DisplayExampleDTO(entity);
    }

    public static List<DisplayExampleDTO> convertList(List<DisplayExample> list) {
        List<DisplayExampleDTO> resultList = new ArrayList<>();
        for (DisplayExample entity : list) {
            resultList.add(new DisplayExampleDTO(entity));
        }
        return resultList;
    }}
